
MT是我使用时间最长的一个博客程序。它基于 Perl,功能强大而且可靠性十分稳妥。然而,在快餐文化异常普及的当下,它显得有点疲态百出。它没有 php 程序的灵活、部署简易,直白点说是折腾。因为站点移到国外的 VPS 的原因,国内连接速度实在不敢恭维,因此 MT 也成了我困难丛丛的选择。无奈只能转投效率优先的 typecho。
因为博客思路设计的差异,我仅仅转换了原来的文章及相关评论。涉及到的数据表也只有 3 个。有需要的朋友可以参考下。将下面的源码保存为 php 文件,放在 typecho 博客根目录然后运行即可。(建议做好相关数据库备份后,在本地转换成功后再上传)
<?php /* Typecho Blog Platform @copyright Copyright(c) 2008 Typecho team(http://www.typecho.org) @version $Id: index.php 1153 2017-03-12 10:53:22Z ezo.biz $ / if(!defined('__TYPECHO_ROOT_DIR__') && !@include_once 'config.inc.php') { file_exists('./install.php') ? header('Location: install.php') : print('Missing Config File');
exit;
}
/*/
#Typecho_Widget::widget('Widget_Init');
$d_MT = "blog"; /* 初始化 mt 数据库 ?)(ezo\.biz\/b\/).)(\.)(gif|jpeg|jpg|png))/i', "/b_img/$5", $post['Entry_text']); $post['Entry_text'] = str_replace("http://ezo.biz","https://ezo.biz",$post['Entry_text']);
$post['Entry_text'] = str_replace("http://www.ezo.biz","https://www.ezo.biz",$post['Entry_text']); $post['Entry_text'] = mysql_real_escape_string($post['Entry_text']);
$post['entry_title'] = mysql_real_escape_string($post['entry_title']); /* 修复 typecho slug 主键唯一的问题 转换评论 */ $b = $dbMT->query("SELECT comment_author,comment_created_on,comment_email,comment_entry_id,comment_ip,comment_text,comment_url FROM mt_comment WHERE comment_visible=1 AND comment_entry_id=$post[entry_id];"); $comments = $dbMT->fetchALL($b); foreach($comments as $comment) { # 批量导入评论 $comment['comment_created_on'] = strtotime($comment['comment_created_on']); $db->query("INSERT INTO (, , , , , , , , , , , , , ) VALUES(NULL, '$cid', '$comment[comment_created_on]', '$comment[comment_author]', '0', '0', '$comment[comment_email]', '$comment[comment_url]', '$comment[comment_ip]', NULL, '$comment[comment_text]', 'comment', 'approved', '0');");
}
}